package com.swh.controller.business;

import com.github.pagehelper.PageInfo;
import com.swh.entity.Qualification;
import com.swh.entity.QualificationCondition;
import com.swh.service.QualificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.HashMap;

/**
 * @Author: swh
 * @Description:
 * @Date: 2020/12/14 14:41
 * @Version: 1.0
 */
@Controller
@RequestMapping("/guguanjia/qualification")
public class QualificationController {

    @Autowired
    private QualificationService qualificationService;

    @RequestMapping("/index")
    public String login() {
        return "/qualification/index";
    }

    @ResponseBody
    @RequestMapping("/findAll/{pageNum}/{pageSize}")
    public PageInfo<HashMap> findAll(@PathVariable("pageNum") int pageNum, @PathVariable("pageSize") int pageSize,
                                     QualificationCondition condition) {
        System.out.println(condition);
        return qualificationService.selectPage(pageNum, pageSize,condition);
    }


    @RequestMapping("/toUpdate")
    public String toUpdate() {
        return "/qualification/update";
    }


    //根据id查询并且回写数据
    @ResponseBody
    @RequestMapping("/get")
    public Object get(Integer id) {
        return qualificationService.findById(id);
    }

    //    审核通过
    @ResponseBody
    @RequestMapping(value = "/updateById", method = RequestMethod.POST)
    public void updateById(@RequestBody Qualification qualification) {
        qualificationService.updateById(qualification);
    }

    //    审核失败
    @ResponseBody
    @RequestMapping(value = "/updateById2", method = RequestMethod.POST)
    public void updateById2(@RequestBody Qualification qualification) {
        qualification.setUpdateDate(new Date());

        qualificationService.updateById2(qualification);
    }

}
